package ma.ensao.evalmetrics.view;




import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

import ma.ensao.evalmetrics.controller.ResultManager;
import ma.ensao.evalmetrics.controller.grapheManager;
import ma.ensao.evalmetrics.model.Result;

import org.jfree.chart.JFreeChart;




import com.opensymphony.xwork2.ActionSupport;
/*
* Génération de Graphe
*/
 
public class graphe extends ActionSupport{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public Long id,idp;
	private JFreeChart chart;
	private ResultManager resultmanager=new ResultManager();
	private Result result;
	 
	private int param;

	public JFreeChart getChart() {
		return chart;
	}
	public void setChart(JFreeChart chart) {
		this.chart = chart;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	public Long getIdp() {
		return idp;
	}
	public void setIdp(Long idp) {
		this.idp = idp;
	}
	public String execute(){
		System.out.println("iiiiiid"+getId()+"param"+getParam());
		if(idp != null ){
			id = idp;
		}
		
		result=resultmanager.LastResult(id);
		
		
		File file=new File("list.txt");
		file.delete();
		FileWriter fw;
		try {
			fw = new FileWriter("list.txt", true);
			BufferedWriter bw = new BufferedWriter(fw);
			PrintWriter pw = new PrintWriter(bw);
			pw.print(getId());
			bw.newLine();
			pw.print(getParam());
			pw.close();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

		
		
		return SUCCESS;
		
	}
	
	public int getParam() {
		return param;
	}
	public void setParam(int param) {
		this.param = param;
	}

	public Result getResult() {
		return result;
	}
	public void setResult(Result result) {
		this.result = result;
	}
	

}
